package cn.qiao.benchmark;

import redis.clients.jedis.Jedis;
import redis.clients.jedis.JedisPool;
import redis.clients.jedis.Pipeline;

/**
 * desc:
 *
 * @author qiao
 * @date 2024年02月05日 21:19
 */
public class JedisServiceImpl implements RedisService{


    private JedisPool jedisPool;


    @Override
    public void set(String key, String value) {
        try(Jedis redis = jedisPool.getResource()){
            redis.set(key,value);
        }
    }

    @Override
    public String get(String key) {
        try(Jedis redis = jedisPool.getResource()){
            return redis.get(key);
        }
    }
    public void pipelined(String key) {
        try(Jedis redis = jedisPool.getResource()){
            Pipeline pipelined = redis.pipelined();
            pipelined.sync();
        }
    }

    public JedisServiceImpl(JedisPool jedisPool) {
        this.jedisPool = jedisPool;
    }
}
